The present invention generally concerns a method and apparatus for determining a shaft position using an optical encoder, and in particular, concerns the determination of the rotational position of a detented optical encoder shaft in a computer input device.
Pointing devices, such as computer mice and trackballs, are used to provide user input to a computer program and to control applications, and are well known in the art. Such pointing devices enable a user to move a cursor on a display screen and are fundamental to programs and operating systems that employ a graphical user interface, such as Microsoft Corporation""s WINDOWS(trademark) and Apple Corporation""s MACINTOSH(trademark) operating systems. In a typical pointing device, a ball is rotated in the housing of the device, either directly by the user""s fingers, or by movement of the device over an underlying surface or pad. Depending upon its direction of rotation, the rotating ball in turn causes one or both of a pair of encoder shafts in the housing to rotate. The encoder shafts rotate about a pair of orthogonal axes, i.e., the xe2x80x9cXxe2x80x9d and xe2x80x9cYxe2x80x9d axes, in response to components of the ball""s rotation along those axes. As the encoder shafts rotate, the corresponding encoders produce signals that indicate the device""s incremental motion along these orthogonal axes. These signals are processed by a microcontroller or other logic in the pointing device, which produces a corresponding stream of digital values indicative of a position of the device relative to the X and Y axes. These displacements are passed to a driver program executing on the computer to which the pointing device is attached. The driver program also receives other input signals from the pointing device, including a signal indicative of the state of control buttons on the device. The relative position data and the state of the control buttons are input to a computer program (or the operating system), which processes the information, causing a predefined action to occur. For example, many operating systems move a cursor displayed on a monitor or other display screen in response to a user""s movement of a pointing device. The X and/or Y movement of the cursor on the display screen is a function of the motion of the ball (or device) along its respective X and/or Y axes.
In recent years, mouse manufacturers have added a third input axis to their products, commonly known as the xe2x80x9cZxe2x80x9d axis. Originally developed by the Microsoft Corporation for use with its WINDOWS(trademark) operating system, this Z-axis control on the mouse is primarily used for scrolling within a document or in a displayed window and is typically implemented using a detented wheel (the Z-wheel) that is coupled to a rotatable shaft. An encoder monitors rotation of the Z-wheel shaft by a user. Detents on the rotational motion of this wheel provide tactile feedback regarding the extent of the rotation of the wheel and enable a user to scroll a document or data display in consistent increments specified by the user, such as a predetermined number of lines/detent, or a screen/detent. The Z-wheel is typically mounted vertically and is disposed toward the front of a mouse so that it can be readily turned with a user""s index or middle finger. The detent positions are typically spaced at increments of about 20xc2x0.
In order to obtain a desired level of performance, the output signal produced by the Z-axis encoder should accurately correspond to the number and direction of detent positions through which the user rotates the Z-wheel. For example, if a user rotates the Z-wheel through five detent positions in a forward direction (rotating the top of the Z-wheel toward the front of the mouse), this movement should be reflected in the corresponding control action applied by the computer program, e.g., by the program scrolling forward in a document displayed on a monitor through five of the scrolling increments/detent previously selected by the user.
Several techniques have been implemented in prior art Z-wheel mice to address this performance requirement. One solution is to use a mechanical encoder with a built-in detent mechanism. In this type of device, a mechanical detent is closely coupled with the encoder that produces an electrical output signal, which satisfies the foregoing performance requirement. However, mechanical encoders of this type generally cost more than may be desired in a product that must compete on price as well as performance. Therefore, a less-expensive optical encoder scheme is preferable for accurately detecting rotation of the Z-wheel through successive detent positions.
Optical encoders are commonly used to detect the motion and/or position of a member, as it moves either linearly or rotationally. Two classes of optical encoders are incremental encoders, and absolute encoders. Incremental rotary encoders are suitable for use in a mouse. Ideally, an incremental encoder produces a pair (two channels) of square wave signals that are approximately 90xc2x0 out of phase, and this type of output signal is thus commonly referred to as a quadrature output. The quadrature output is processed to determine the extent of rotation of an element (such as a wheel) monitored by the encoder, and the direction of the element""s rotation.
The primary components of a typical optical encoder (prior art) are shown in FIGS. 1 and 2, and include a codewheel or code disk 10, an emitter 12, and an integrated detector circuit 14. The codewheel generally comprises a plurality of equally-spaced teeth 16, forming slots 18, which may be fully enclosed, or it may be fabricated using a clear plastic or glass disk imprinted with a radially-spaced pattern of lines, commonly called a xe2x80x9cmask.xe2x80x9d Emitter 12 typically comprises an LED 20, which emits light rays 21 that are collimated into a parallel beam by a lens 22. Integrated detector circuit 14 is disposed opposite the emitter and typically comprises at least two photodetectors 24 (as shown in FIG. 2), or two sets of photodetectors (as shown in FIG. 1), noise reduction circuitry 26, and comparators 28. Suitable photodetectors include photodiodes and phototransistors. The set of components comprising the emitter and photodetectors used in an optical encoder is commonly referred to as the encoder""s xe2x80x9cphoto-optics.xe2x80x9d
The codewheel is disposed relative to the emitter and integrated detector circuit so that when it is rotated, its slotted or lined portion moves between the emitter and integrated detector circuit. The light beam passing from the emitter to the integrated detector circuit is thus interrupted by the part of the codewheel between the pattern of slots or by the radial lines on the codewheel. Any portion of the light beam that is not blocked by the codewheel (or the lines that are imprinted) is detected by the photodetectors. The photodetectors typically produce an analog output signal that is proportional to the intensity of light they detect. In general, the output signal produced by each photodetector as the codewheel is turned at a constant rate is sinusoidal. The photodetectors are arranged in a pattern that is a function of the radius and slot or line density of the codewheel, so as to produce a quadrature output.
In the embodiment shown in FIG. 1, the photodetectors are spaced such that a light period (i.e., when light passes through the codewheel) on one pair of photodetectors corresponds to a dark period (i.e., when the codewheel blocks the light) on an adjacent pair of photodetectors, thereby producing two complementary outputs for each channel. The photodetector outputs are processed by the noise reduction circuitry, which removes extraneous noise. The resulting four signals are then evaluated by the comparators (one comparator for each complementary pair of signals), producing a digital waveform corresponding respectively to the encoder output for channels A and B. The digital waveform has voltage levels corresponding to a logic level zero and a logic level one. If the encoder wheel is turned at a constant angular rate, the output signals on channels A and B will be similar to the waveforms shown in FIG. 3C, wherein the digital waveform of channel A is approximately 90xc2x0 out of phase (in quadrature) with that of channel B. In actual practice, the waveforms are not perfectly square waves due to signal propagation delays, switching latencies, etc.; however, they approximate square waves.
The quadrature output of an encoder can be evaluated to determine the present state of the encoder and the direction that the encoder shaft is being turned or is moving. FIG. 3B shows a typical state table corresponding to a full quadrature encoding scheme, and the corresponding state transitions are shown in FIG. 3A. The state of the encoder is dependent on the logic value of each channel. For example, if the logic values of channels A and B are respectively 1 and 0 (represented simply as xe2x80x9c(10)xe2x80x9d), the state is 1. By examining changes in the state of the encoder, it is possible to determine the present position of the encoder by integrating its incremental motion. A common scheme used to perform this task is shown in FIG. 3C, wherein the state is evaluated at each falling edge of a clock input signal. The direction of rotation of the encoder wheel can also be determined by determining which channel leads the other, e.g., A leading B indicates clockwise rotation of the wheel, while B leading A indicates counterclockwise rotation of the wheel.
FIG. 3D shows a state transition table corresponding to the full quadrature transition states discussed above. The state transition table indicates when a transition is reported based on a sensed change in the position of the encoder wheel. In the case of full quadrature encoding, every change in state on either channel produces either a xe2x80x9c+xe2x80x9d or xe2x80x9cxe2x88x92xe2x80x9d change in the output produced by processing the channels. Put another way, there are two state changes for each change in the output signal on a given channel. As a result, this scheme multiplies the resolution of the encoder wheel by four. For an encoder wheel with X teeth, the resolution with which rotation of the wheel can be monitored is four times X, and this type of quadrature encoding is referred to as 4X encoding.
The foregoing optical encoder has several drawbacks when used in a mouse or trackball. A primary problem is that it is too expensive. Each photodiode has a significant cost, and the noise reduction circuitry and comparators also add to the expense of the encoder. Another problem is that the integrated detector circuit portion of the encoder generally takes up too much space. Additionally, the level of precision required for an input axis on a mouse is much lower than the level of precision required in other applications that typically often employ optical encoders of the foregoing design, such as motion controllers, robotics, etc.
In order to address the size and cost limitations of encoders suitable for use in a mouse, engineers developed an optical encoder scheme that requires fewer components and is much less costly to manufacture. An example of such a prior art scheme is shown in FIG. 4. As shown therein, the detection circuit has been reduced to a pair of phototransistors 30, each of which produces an analog output signal applied respectively to a non-inverting Schmitt trigger 32. The Schmitt triggers are used to minimize the effects of extraneous noise in the raw signals provided by the phototransistors. Optionally, other types of comparator circuits can be used in place of the Schmitt triggers. The output signals of the Schmitt triggers are input to a microcontroller, which processes the signals on channels A and B using a special duty-cycle control algorithm to generate a digital waveform in quadrature, which is further processed by the microcontroller to determine the incremental motion of the encoder wheel. The output from the microcontroller is then passed through a serial communication link to a computer (e.g., through an RS-232 serial port, a universal serial bus (USB) port, or a PS/2 port). A driver in the operating system (or in an application program) processes the output from the microcontroller to control the display of a cursor on the computer monitor screen in response to the movement of the mouse Z-wheel.
As might be expected, the waveforms produced by the phototransistor/Schmitt trigger/duty-cycle control algorithm scheme of FIG. 4 are not as accurate and clean as the waveforms produced by the detection circuit of FIG. 1. Due to the lower accuracy of the waveforms, there is a higher probability that a logic level change (a transition between a high and low voltage level or vice versa) on a channel might be missed, or that a false logic level change might be indicated. Either of these situations would cause the sensed movement of the encoder wheel to differ from the actual movement of the wheel, and the movement of the Z-wheel would thus be inaccurately reflected in the control action implemented by the computer. To overcome this problem, a different state transition scheme was developed, as shown in FIGS. 5A and 5B (prior art). In this transition state scheme, there are two electrical state changes required for each detent position of the encoder wheel. This scheme reduces the impact of missed state transitions and false signals, but is still susceptible to many problems when used with a detented Z-wheel control.
A primary problem that occurs in detented encoders that employ optical encoders to detect motion is that the mechanical detent positions may not always be or remain synchronized relative to the occurrence of valid opto-electrical state changes. This is typically caused by variations in the dimensions, performance, and location of the various parts that make up an assembled encoder, wear and fatigue problems that occur over the lifetime of the device, and noise problems due to electrostatic discharge and/or ambient lighting conditions. Such is the case with the prior art device of FIG. 2.
As shown in FIG. 2, a common detent mechanism employs a leaf spring 50 with a protrusion 52 on one end that applies a bias force against evenly-spaced longitudinal slots 54 formed in a portion of a rotatable shaft 56. As the shaft is rotated, the protrusion, acting under the biasing force of the spring, moves in and out of successive slots, which flexes the spring back and forth, thereby creating a detent action. The even spacing of the slots in the shaft results in a user feeling a plurality of evenly-spaced detented positions as the user rotates a wheel 58 that is mounted on the shaft.
The force required to move the wheel from one detent position to the next varies with the angular position of the wheel as it is rotated between the detent positions. FIG. 6 illustrates the relative displacement of the protrusion 52 with respect to the slots 54 as the shaft 56 is rotated. The rotational force or torque necessary to achieve this displacement is approximated by the derivative of this displacement curve. For instance, when the wheel is disposed at a detent position, it requires relatively little force to rotate it away from that detent position (i.e., the slope of the curve immediately adjacent the detent position is relatively flat on both sides), while a substantially larger amount of rotational force is required to turn the wheel to an adjacent detent position, as indicated by the vertical portions of the curve.
Under optimal circumstances, there should be a tendency for the Z-axis wheel to always return to a detent position if a user releases the wheel (stops applying a rotational force to the wheel), regardless of the rotational angle of the wheel when it is released. However, as shown in the region enclosed by the ellipse in the graph of FIG. 6 and as indicated by the corresponding arc in FIG. 7, there are areas between detent positions, known as xe2x80x9cbalance areas,xe2x80x9d where the wheel will hang and not return to a detent position if it is released. (If the wheel is released outside of one these balance areas, the position of the wheel will always move to the nearest detent position, as is desired.) Due to friction, the balance area for rotation of the wheel in a forward direction is not always coincident with the balance area for rotation of the wheel in a reverse direction.
FIG. 6 also illustrates another problem that can be encountered with a detented optical encoder, known as xe2x80x9cbounce back.xe2x80x9d Bounce back occurs when a user rolls the wheel forward quickly and then releases the wheel just prior to passing through a balance point to the next detent position. If the wheel has been rolled forward rapidly, it is possible for angular momentum to cause the wheel to continue rolling for a short duration in its present direction after the user has released the wheel. The wheel will slow down, stop, and then return to the previous detent position. If the electrical system senses a transition point prior to the direction of wheel rotation self-reversing, the result will be that the last electrical count is reported in a direction opposite that in which the user was rolling the encoder wheel. This problem will be more clearly understood from the following explanation.
With reference to FIG. 6, at position A, the encoder wheel is moving forward and a forward transition is reported, as indicated by a xe2x80x9c+.xe2x80x9d At position B, the encoder wheel is moving forward and a second forward transition is reported. Between positions B and C, the user releases the encoder wheel, but the angular momentum causes the encoder wheel to continue rolling forward. At position C, the encoder wheel is moving forward very slowly, but a forward transition is reported. Just after position C, the encoder wheel stops, but changes direction and returns to the previous detent position. However, at position D, the encoder wheel is rolling backward, and a backward transition is reported. At position E, the encoder wheel comes to rest. As a result of the preceding scenario, an extra forward transition and an extra backward transition are registered by the encoder, even though the user did not intend the transitions C+ and Dxe2x88x92 to be registered. These erroneous transition registrations can be quite bothersome, especially if a user is working on a relatively slow computer on which a lag between the time a scrolling request is received and the time that the display or data actually scrolls is very evident. In this case, the user would be forced to wait for the false forward and backward transitions to be implemented on the display before continuing to work on the document or data.
Ideally, the reporting of a transition state change indicating a user movement of the wheel to a new detent position (called the transition point) should occur just after passing the balance area. At this point, it is certain that the encoder wheel will move to the next detent position if the user releases the wheel, and bounce back cannot occur. In addition, it is preferable that the reported transition point (i.e., the angle at which the encoder wheel is when a transition is reported) on both a forward and reverse encoder wheel motion occurs at repeatable positions.
It is not practical to achieve the foregoing desires with the prior art designs discussed above, due to the part and assembly variances commonly associated with the manufacture of large lots of product. For example, a variation of a mere 0.001xe2x80x3 in the location of the protrusion on the leaf spring results in a 0.5-degree (ARCTAN [0.001/0.117]) shift in the transition angle. In addition, the prior art design presents numerous situations where mechanical tolerance stack-up due to part tolerance variation is considered. The variation in the dimensions of the parts comprising the encoder assembly and/or the variation in the assembled position of these parts can cause the reported transition points to be out of tolerance relative to the detent positions. In order to meet a required performance requirement, the tolerances on the parts that comprise the prior art assembly would have to be so tight that the cost of this assembly would be prohibitive, particularly for use in the Z-wheel shaft encoder assembly of a pointing device.
Furthermore, in the prior art design, the location of some of the components may change over time, due to creep and/or wear. For example, the leaf spring constantly applies a lateral force to the shaft, which is transferred to a bearing surface in a support bracket (not shown) that provides a rotatable support for the shaft. As a result, this transferred lateral force produces a bending moment about the base of the support bracket, which eventually may cause the location of the bearing to creep (i.e., shift) relative to the rest of the assembly. As a result, the location of the codewheel relative to the emitter and photodetector may change, causing the transition point to shift as well. Another problem occurs as a result of wear on the contacting surfaces and/or fatigue in the spring. As a result, the mechanical accuracy of the detented positions relative to the encoder output signal may change over time. Because of these and other problems, exemplary angular ranges 90 and 92 shown in FIG. 8 are specified to define the acceptable range for the transition point to occur relative to the angular position of the wheel between adjacent detents.
An additional problem associated with detented optical encoders is known as an xe2x80x9codd/evenxe2x80x9d error. This error arises in an encoder for a wheel that does not report transitions in the same location from detent to detent. For even detents, the transitions may occur early in the force curve, while for odd detents, the transitions occur late, which is due to the electrical system not properly adjusting to the output gain and/or position of the photodetectors. Using the quadrature transition table of FIG. 5B, the electrical system reports counts whenever it sees a transition on a single phototransistor. A transition is detected when a processed phototransistor output changes from xe2x80x9c0xe2x80x9d to xe2x80x9c1.xe2x80x9d The next time that a transition is detected (if the wheel is moving in the same direction) will be when the output signal changes from xe2x80x9c1xe2x80x9d to xe2x80x9c0.xe2x80x9d For a very sensitive photodetector system, all xe2x80x9c0 to 1xe2x80x9d transitions will occur early (i.e., the photodetector only requires xcx9c25% exposure to light to output a xe2x80x981xe2x80x99) and all xe2x80x9c1 to 0xe2x80x9d transitions will occur late (i.e., it requires xcx9c75% of the photodetector to be occluded to output a xe2x80x980xe2x80x99). The opposite is true for a photodetector pair that has relatively low sensitivity. Due to this problem, the specified photodetector pair performance must be higher than desired, leading to the rejection of many vendor-supplied photodetector pairs during manufacturing of the pointing device.
Still another problem with detented optical encoders is caused by jitter, which occurs when the particular orientation of the various components of the encoder relative to one another, combined with the system""s electrical noise, cause the output produced on one of the channels to fluctuate about the threshold voltage, producing an indeterminate position indication. For instance, due to jitter, a quadrature sequence of 00= greater than 01= greater than 00= greater than 00= greater than 01 may be reported by a conventional encoder as a transition of +1, xe2x88x921, etc., when in actuality, the Z-axis wheel is not moving.
It would therefore be desirable to provide a detented optical encoder control device that avoids the problems of the prior art devices discussed above. Such a device should eliminate or minimize the effects of bounce back, should minimize the effect of the odd/even error, and should enable the use of both high and low sensitivity photo-optic components, as well as unmatched photo-optic sets without concern for producing jitter or erroneous results.
One aspect of the present invention is directed to a method that addresses the foregoing problems when determining the position of a detented control wheel and is suitable for use in a pointing device. Through the use of a novel quadrature state change table and a physical-to-logical quadrature state conversion process, a transition point is reported only after passing a balance point, thereby minimizing or eliminating the effect of bounce back. The quadrature state change table employed also provides a position change indication when the detented control wheel is moved between adjacent detent positions even if one of the quadrature states that would normally be required to be detected to invoke the position change indication is missed. The method also enables unmatched photo-optic sets to be used by combining a duty-cycle encoding scheme and a feedback mechanism that provides for continuous readjustment throughout the lifetime of the pointing device.
In accord with the method, a change is determined in a detent position of a detented wheel operatively coupled to an optical encoder that produces a quadrature output signal. The quadrature output signal includes a first, a second, a third, and a fourth quadrature state that change as the detented wheel is rotated in a forward or a reverse direction between successive detented positions. The method includes the step of monitoring and processing the quadrature output signal from the optical encoder as the detented wheel is rotated; the quadrature output signal that is processed comprises a plurality of successive quadrature states. Quadrature state change conditions are defined that invoke position change indications corresponding to a change in the detent position. In each of the forward and reverse directions, there exists a single predefined quadrature state change condition between a predefined pair of adjacent quadrature states that invokes a position change indication corresponding to the direction. In addition, the quadrature state change conditions compensate for a missing quadrature-state change in detecting a change in detent position. Position change indications are output, based on changes between successive quadrature states and the quadrature state change conditions that are defined, so as to provide an indication of the rotation direction and the detent position of the detented wheel.
The step of defining the quadrature state change conditions preferably comprises the step of creating a quadrature state table that comprises a plurality of entries defining the quadrature state change conditions. Each entry in the quadrature state table comprises a state change between one of the first, second, third, or fourth quadrature states and another quadrature state, and includes an indication of whether the quadrature state change corresponds to the forward or the reverse direction of wheel rotation. The single predefined quadrature state change condition invokes a position change indication for the forward direction when a change between the second quadrature state and the third quadrature state occurs. The quadrature state table further includes entries indicating a position change in the forward direction that compensate for missed quadrature state changes, such that a position change in the forward direction is indicated when the quadrature state changes from the second quadrature state to the fourth quadrature state, or from the first quadrature state to the third quadrature state.
Similarly, in the quadrature state table, there is an indication of whether the quadrature state change corresponds to the forward or the reverse direction of wheel rotation. The single predefined quadrature state change condition invokes a position change indication for the reverse direction when a change between the second quadrature state and the first quadrature state occurs. Also, the quadrature state table includes entries indicating a position change in the reverse direction compensating for missed quadrature state changes, such that a position change in the reverse direction is indicated when the quadrature state changes from the third quadrature state to the first quadrature state, or from the second quadrature state to the fourth quadrature state.
The fourth quadrature state corresponds to the quadrature output signal that was processed when the detented wheel is in a detent position, for either of the preceding cases that compensate for missing quadrature states. A distinction is made between physical and logical quadrature states. The quadrature output signals from the optical encoder that are monitored and processed comprise physical quadrature states, while the plurality of entries in the quadrature state table defining the quadrature state change conditions comprise logical quadrature states. The optical encoder outputs a detent physical quadrature state when the detented wheel is in a detent position. The method thus further includes the step of determining to which of the first, second, third, or fourth quadrature states the detent physical quadrature state corresponds. The physical quadrature state is converted to a logical quadrature state so that when the detented wheel is rotated between adjacent detent positions, a position change indication is output within a predefined range of rotation relative to the adjacent detent positions. Specifically, a position change indication is normally output indicating a change to an adjacent detent position after three logical quadrature state changes are traversed.
The step of determining to which of the first, second, third, or fourth quadrature states the detent physical quadrature state corresponds comprises the step determining an elapsed time between successive quadrature state changes. If the elapsed time exceeds a predetermined threshold, the physical quadrature state is recorded, whereupon if the physical quadrature state remains the same for another predetermined elapsed time, the detent physical quadrature state is set equal to the physical quadrature state. In addition, the algorithm prevents the balance point from being misinterpreted as the detent position (since the wheel could stop there indefinitely) by using a priori knowledge of the mechanical system.
The step of converting from the physical quadrature states to the logical quadrature states is preferably implemented through the use of a lookup table. The lookup table lists the four quadrature states, each quadrature state having an index value based on a location of that quadrature state within the list, and defines a logical detent quadrature state. The step of converting from physical quadrature states to logical quadrature states further comprises the step setting an index lookup equal to the physical detent quadrature state. A quadrature state in the lookup table having an index value equal to the index lookup is identified. A detent index of the quadrature state in the lookup table corresponding to the logical detent quadrature state is then determined, and a logical quadrature index is determined as a function of the quadrature state that was identified and the detent index. The quadrature state in the lookup table having an index value equal to the logical quadrature index is identified and set equal to the logical quadrature state.
Another aspect of the present invention is directed to a user input control that includes elements carrying out functions that are generally consistent with the steps of the method described above.